<template>
  <div>
    <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="我真的一滴都没有了"
        @load="onLoad"
      >
        <slot></slot>
      </van-list>
    </van-pull-refresh>
  </div>
</template>



<script>
import { Toast } from "vant";
export default {
  data() {
    return {
      isLoading: false,
      loading: false,
      finished: false, //数据已经全部加载
    };
  },
  props: {
    refreshdata: Function,
  },
  methods: {
    onRefresh() {
      setTimeout(() => {
        this.refreshdata(() => {
          Toast("刷新成功");
          this.isLoading = false;
        });
      }, 800);
    },
    onLoad() {
      setTimeout(() => {
        this.refreshdata(() => {
          Toast("刷新成功");
          this.isLoading = false;
        });
      }, 200);
    },
  },
};
</script>